<?php

session_start();

require_once ("../../../db.php");


if (!isset($_SESSION['uid']) || ($_SESSION['type'] != 'student')) {
    die('Not logged in as an student user');
}
// this will insert a projectrequest into the database
$sql = 'INSERT INTO projectrequest(projectid, groupid, priority, `date`) VALUES (?, ?, ?, now())';
$sth = $db->prepare($sql);
$res = $sth->execute(array($_POST['projectid'], $_POST['groupid'], $_POST['prio'])); // with project id, group id and prioritet
if($res){
    echo json_encode(array('success' => 'Request lagt til'));
} else {
    echo json_encode(array('error' => 'Request feilet'));
}